#include <stdlib.h>

#include "kgamemastergui.h"

KGameMasterGui::KGameMasterGui(QWidget* parent) 
	: QMainWindow(parent) {

	setObjectName(QString::fromUtf8("MainWindow"));
	setMinimumSize(QSize(800, 600));

	createActions();
	createCentralWidget();
	createMenuBar();
	createStatusBar();
	createToolBar();

	createPlacesDock();
	createCharactersDock();
	createObjectsDock();
	menuView->addSeparator();
	createPropertiesDock();
	createTextDock();
	createConnections();

	retranslateUi();

}

void KGameMasterGui::createConnections(){

	//Actions
	connect(actionNew, SIGNAL(triggered()), this, SLOT(newFile()));
	connect(actionClose, SIGNAL(triggered()), this, SLOT(close()));
	
	//Trees
	connect(treePlaces, SIGNAL(itemClick()), this, SLOT(newFile()));
	

}

void KGameMasterGui::createCentralWidget(){

	centralwidget = new QWorkspace(this);
	centralwidget->setObjectName(QString::fromUtf8("centralwidget"));

	setCentralWidget(centralwidget);
}

void KGameMasterGui::createActions(){

    actionNew = new QAction(this);
    actionNew->setObjectName(QString::fromUtf8("actionNew"));
	

    actionClose = new QAction(this);
    actionClose->setObjectName(QString::fromUtf8("actionClose"));
}

void KGameMasterGui::createMenuBar(){

	menubar = new QMenuBar(this);
	menubar->setObjectName(QString::fromUtf8("menubar"));
	menubar->setGeometry(QRect(0, 0, 812, 29));

	menuFile = new QMenu(menubar);
	menuFile->setObjectName(QString::fromUtf8("menuFile"));

	menuEdit = new QMenu(menubar);
	menuEdit->setObjectName(QString::fromUtf8("menuEdit"));

	menuView = new QMenu(menubar);
	menuView->setObjectName(QString::fromUtf8("menuView"));

	menuHelp = new QMenu(menubar);
	menuHelp->setObjectName(QString::fromUtf8("menuHelp"));

	setMenuBar(menubar);

	menubar->addAction(menuFile->menuAction());
	menubar->addAction(menuEdit->menuAction());
	menubar->addAction(menuView->menuAction());
	menubar->addAction(menuHelp->menuAction());

	menuFile->addAction(actionNew);
	menuFile->addAction(actionClose);
}

void KGameMasterGui::createStatusBar(){

	statusbar = new QStatusBar(this);
	statusbar->setObjectName(QString::fromUtf8("statusbar"));
	statusbar->setGeometry(QRect(0, 578, 812, 22));

	setStatusBar(statusbar);
}

void KGameMasterGui::createToolBar(){

	toolBar = new QToolBar(this);
	toolBar->setObjectName(QString::fromUtf8("toolBar"));
	toolBar->setAcceptDrops(false);
	toolBar->setMovable(false);
	toolBar->setOrientation(Qt::Horizontal);
	toolBar->setIconSize(QSize(24, 24));
	toolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);

	addToolBar(static_cast<Qt::ToolBarArea>(4), toolBar);

	btnTown = new KGMToolButton(this, 
								QIcon(QString::fromUtf8(":/images/building.png")),
								"townIcon");
	btnTown->setObjectName(QString::fromUtf8("btnTown"));
	
	btnDungeon = new KGMToolButton(this, 
								QIcon(QString::fromUtf8(":/images/dungeon_icon.png")),
								"dungeonIcon");
	btnDungeon->setObjectName(QString::fromUtf8("btnDungeon"));
	
	btnRoom = new KGMToolButton(this, 
								QIcon(QString::fromUtf8(":/images/chair.png")),
								"roomIcon");
	btnRoom->setObjectName(QString::fromUtf8("btnRoom"));

	toolBar->addWidget(btnTown);
	toolBar->addWidget(btnDungeon);
	toolBar->addWidget(btnRoom);

}

void KGameMasterGui::createTextDock(){

	dockText = new QDockWidget(this);
	dockText->setObjectName(QString::fromUtf8("dockText"));
	dockText->setMinimumSize(QSize(800, 125));

	txtCodigo = new QTextEdit(dockText);
	txtCodigo->setObjectName(QString::fromUtf8("txtCodigo"));
	txtCodigo->setGeometry(QRect(15, 1, 780, 100));
	txtCodigo->setMinimumSize(QSize(780, 100));

	dockText->setWidget(txtCodigo);
	menuView->addAction(dockText->toggleViewAction());
	addDockWidget(static_cast<Qt::DockWidgetArea>(8), dockText);
}

void KGameMasterGui::createPropertiesDock(){

	dockProperties = new QDockWidget(this);
	dockProperties->setObjectName(QString::fromUtf8("dockProperties"));

	tabProperties = new QTabWidget(dockProperties);
	tabProperties->setObjectName(QString::fromUtf8("tabProperties"));
	tabProperties->setGeometry(QRect(10, 0, 181, 341));

	tab = new QWidget();
	tab->setObjectName(QString::fromUtf8("tab"));
	tabProperties->addTab(tab, QApplication::translate("MainWindow", "Tab 1", 0, QApplication::UnicodeUTF8));

	tab_2 = new QWidget();
	tab_2->setObjectName(QString::fromUtf8("tab_2"));
	tabProperties->addTab(tab_2, QApplication::translate("MainWindow", "Tab 2", 0, QApplication::UnicodeUTF8));

	dockProperties->setWidget(tabProperties);
	menuView->addAction(dockProperties->toggleViewAction());
	addDockWidget(static_cast<Qt::DockWidgetArea>(2), dockProperties);
}

void KGameMasterGui::createPlacesDock(){

	dockPlaces = new QDockWidget(this);
	dockPlaces->setObjectName(QString::fromUtf8("dockPlaces"));

	//treePlaces = new QTreeWidget(dockPlaces);
	treePlaces = new KGMTreeWidget(dockPlaces);
	treePlaces->setObjectName(QString::fromUtf8("treePlaces"));
	treePlaces->setGeometry(QRect(0, 0, 181, 111));
	
	dockPlaces->setWidget(treePlaces);
	menuView->addAction(dockPlaces->toggleViewAction());
	addDockWidget(static_cast<Qt::DockWidgetArea>(1), dockPlaces);
}

void KGameMasterGui::createCharactersDock(){

	dockCharacters = new QDockWidget(this);
	dockCharacters->setObjectName(QString::fromUtf8("dockCharacters"));

	//treeCharacters = new QTreeWidget(dockCharacters);
	treeCharacters = new KGMTreeWidget(dockCharacters);
	treeCharacters->setObjectName(QString::fromUtf8("treeCharacters"));
	treeCharacters->setGeometry(QRect(0, 0, 181, 91));

	dockCharacters->setWidget(treeCharacters);
	menuView->addAction(dockCharacters->toggleViewAction());
	addDockWidget(static_cast<Qt::DockWidgetArea>(1), dockCharacters);
}

void KGameMasterGui::createObjectsDock(){
	dockObjects = new QDockWidget(this);
	dockObjects->setObjectName(QString::fromUtf8("dockObjects"));

	//treeObjects = new QTreeWidget(dockObjects);
	treeObjects = new KGMTreeWidget(dockObjects);
	treeObjects->setObjectName(QString::fromUtf8("treeObjects"));
	treeObjects->setGeometry(QRect(0, 0, 181, 81));

	dockObjects->setWidget(treeObjects);
	menuView->addAction(dockObjects->toggleViewAction());
	addDockWidget(static_cast<Qt::DockWidgetArea>(1), dockObjects);
}

    void KGameMasterGui::retranslateUi(){
		setWindowTitle(QApplication::translate("MainWindow", "KGameMaster", 0, QApplication::UnicodeUTF8));

		btnTown->setText(QApplication::translate("MainWindow", "Town", 0, QApplication::UnicodeUTF8));
		btnDungeon->setText(QApplication::translate("MainWindow", "Dungeon", 0, QApplication::UnicodeUTF8));
		btnRoom->setText(QApplication::translate("MainWindow", "Room", 0, QApplication::UnicodeUTF8));

    	actionNew->setText(QApplication::translate("MainWindow", "New", 0, QApplication::UnicodeUTF8));
    	actionClose->setText(QApplication::translate("MainWindow", "Close", 0, QApplication::UnicodeUTF8));

		menuFile->setTitle(QApplication::translate("MainWindow", "File", 0, QApplication::UnicodeUTF8));
		menuHelp->setTitle(QApplication::translate("MainWindow", "Help", 0, QApplication::UnicodeUTF8));
		menuEdit->setTitle(QApplication::translate("MainWindow", "Edit", 0, QApplication::UnicodeUTF8));
		menuView->setTitle(QApplication::translate("MainWindow", "View", 0, QApplication::UnicodeUTF8));

		dockText->setWindowTitle(QApplication::translate("MainWindow", "Scheme Source", 0, QApplication::UnicodeUTF8));
		dockPlaces->setWindowTitle(QApplication::translate("MainWindow", "Places", 0, QApplication::UnicodeUTF8));
		dockProperties->setWindowTitle(QApplication::translate("MainWindow", "Thing Properties", 0, QApplication::UnicodeUTF8));

		tabProperties->setTabText(tabProperties->indexOf(tab), QApplication::translate("MainWindow", "Tab 1", 0, QApplication::UnicodeUTF8));
		tabProperties->setTabText(tabProperties->indexOf(tab_2), QApplication::translate("MainWindow", "Tab 2", 0, QApplication::UnicodeUTF8));

		dockCharacters->setWindowTitle(QApplication::translate("MainWindow", "Characters", 0, QApplication::UnicodeUTF8));
		dockObjects->setWindowTitle(QApplication::translate("MainWindow", "Objects", 0, QApplication::UnicodeUTF8));

		treePlaces->headerItem()->setText(0, QApplication::translate("MainWindow", "", 0, QApplication::UnicodeUTF8));
		treePlaces->clear();

		QTreeWidgetItem *__item = new QTreeWidgetItem(treePlaces);
		__item->setData(0 ,Qt::UserRole, QVariant(QString("Worldmap")));
		__item->setText(0, QApplication::translate("MainWindow", "Worldmap", 0, QApplication::UnicodeUTF8));

		QTreeWidgetItem *__item1 = new QTreeWidgetItem(__item);
		__item1->setText(0, QApplication::translate("MainWindow", "Town1", 0, QApplication::UnicodeUTF8));

		QTreeWidgetItem *__item2 = new QTreeWidgetItem(__item1);
		__item2->setText(0, QApplication::translate("MainWindow", "Bulding1", 0, QApplication::UnicodeUTF8));

		QTreeWidgetItem *__item3 = new QTreeWidgetItem(__item2);
		__item3->setText(0, QApplication::translate("MainWindow", "Room1", 0, QApplication::UnicodeUTF8));

		treeCharacters->headerItem()->setText(0, QApplication::translate("MainWindow", "", 0, QApplication::UnicodeUTF8));
		treeCharacters->clear();

		QTreeWidgetItem *__item4 = new QTreeWidgetItem(treeCharacters);
		__item4->setText(0, QApplication::translate("MainWindow", "Player", 0, QApplication::UnicodeUTF8));

		QTreeWidgetItem *__item5 = new QTreeWidgetItem(__item4);
		__item5->setText(0, QApplication::translate("MainWindow", "Graboth", 0, QApplication::UnicodeUTF8));

		QTreeWidgetItem *__item6 = new QTreeWidgetItem(treeCharacters);
		__item6->setText(0, QApplication::translate("MainWindow", "NPCs", 0, QApplication::UnicodeUTF8));

		QTreeWidgetItem *__item7 = new QTreeWidgetItem(__item6);
		__item7->setText(0, QApplication::translate("MainWindow", "Farmer", 0, QApplication::UnicodeUTF8));

		QTreeWidgetItem *__item8 = new QTreeWidgetItem(treeCharacters);
		__item8->setText(0, QApplication::translate("MainWindow", "Fiends", 0, QApplication::UnicodeUTF8));

		QTreeWidgetItem *__item9 = new QTreeWidgetItem(__item8);
		__item9->setText(0, QApplication::translate("MainWindow", "Monster", 0, QApplication::UnicodeUTF8));

		treeObjects->headerItem()->setText(0, QApplication::translate("MainWindow", "", 0, QApplication::UnicodeUTF8));
		treeObjects->clear();

		QTreeWidgetItem *__item10 = new QTreeWidgetItem(treeObjects);
		__item10->setText(0, QApplication::translate("MainWindow", "Equipment", 0, QApplication::UnicodeUTF8));

		QTreeWidgetItem *__item11 = new QTreeWidgetItem(__item10);
		__item11->setText(0, QApplication::translate("MainWindow", "Weapons", 0, QApplication::UnicodeUTF8));

		QTreeWidgetItem *__item12 = new QTreeWidgetItem(__item11);
		__item12->setText(0, QApplication::translate("MainWindow", "Long Sword", 0, QApplication::UnicodeUTF8));

		QTreeWidgetItem *__item13 = new QTreeWidgetItem(__item10);
		__item13->setText(0, QApplication::translate("MainWindow", "Armors", 0, QApplication::UnicodeUTF8));

		QTreeWidgetItem *__item14 = new QTreeWidgetItem(__item13);
		__item14->setText(0, QApplication::translate("MainWindow", "Full Plate", 0, QApplication::UnicodeUTF8));

		QTreeWidgetItem *__item15 = new QTreeWidgetItem(__item10);
		__item15->setText(0, QApplication::translate("MainWindow", "Accesories", 0, QApplication::UnicodeUTF8));

		QTreeWidgetItem *__item16 = new QTreeWidgetItem(__item15);
		__item16->setText(0, QApplication::translate("MainWindow", "Ring", 0, QApplication::UnicodeUTF8));

		QTreeWidgetItem *__item17 = new QTreeWidgetItem(treeObjects);
		__item17->setText(0, QApplication::translate("MainWindow", "Items", 0, QApplication::UnicodeUTF8));

		QTreeWidgetItem *__item18 = new QTreeWidgetItem(__item17);
		__item18->setText(0, QApplication::translate("MainWindow", "Potions", 0, QApplication::UnicodeUTF8));

		QTreeWidgetItem *__item19 = new QTreeWidgetItem(__item18);
		__item19->setText(0, QApplication::translate("MainWindow", "Healing", 0, QApplication::UnicodeUTF8));

		QTreeWidgetItem *__item20 = new QTreeWidgetItem(__item17);
		__item20->setText(0, QApplication::translate("MainWindow", "Scrolls", 0, QApplication::UnicodeUTF8));

		QTreeWidgetItem *__item21 = new QTreeWidgetItem(__item20);
		__item21->setText(0, QApplication::translate("MainWindow", "Fireball", 0, QApplication::UnicodeUTF8));

		QTreeWidgetItem *__item22 = new QTreeWidgetItem(__item17);
		__item22->setText(0, QApplication::translate("MainWindow", "Misc", 0, QApplication::UnicodeUTF8));

		QTreeWidgetItem *__item23 = new QTreeWidgetItem(__item22);
		__item23->setText(0, QApplication::translate("MainWindow", "Key", 0, QApplication::UnicodeUTF8));
		
		QTreeWidgetItem *__item24 = new QTreeWidgetItem(__item22);
		__item24->setText(0, QApplication::translate("MainWindow", "Map", 0, QApplication::UnicodeUTF8));
    }

void KGameMasterGui::newFile()
{
    qWarning( "KGameMasterGui::newFile(): Not implemented yet" );
}
